package better;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class Test03 {
    public static void main(String[] args) throws Exception {
        Connection connection = JDBCUtils.getConnection();
        String sq11 = "UPDATE emp SET sal = 10000 WHERE empno=?";
        String sql2 = "UPDATE emp SET sal = 12000 WHERE empno=?";
        PreparedStatement ps1 = connection.prepareStatement(sq11);
        PreparedStatement ps2 = connection.prepareStatement(sql2);

        ps1.setInt(1, 7369);
        ps1.setInt(1, 7499);

        connection.setAutoCommit(false);

        try {
            ps1.executeUpdate();
            System.out.println(9 / 0);
            ps2.executeUpdate();
        } catch (Exception e) {
            connection.rollback();
        }
        connection.commit();

        JDBCUtils.close(connection, ps1, null);
        JDBCUtils.close(connection, ps2, null);
    }
}
